import request from "@/utils/request";
const ARTICLE_API = "/merchant/cms/article";
const ARTICLE_API_BASE = "/merchant/article";
/**
 * 文章分类管理----------------------------------------------------------
 *
 * @returns
 */
// 查询装修知识分类列表
export function getDecorationCategory(type) {
  return request({
    url: ARTICLE_API + "/category/page",
    // url: '/decorationCategory/list/' + categoryId,
    method: "get",
    params: {
      type: type,
    },
  });
}

// 新增装修知识分类
export function addEditDecorationCategory(data) {
  return request({
    url: ARTICLE_API + "/category/add",
    method: "post",
    data: data,
  });
}

// 修改装修知识分类
export function updateDecorationCategory(data) {
  return request({
    url: ARTICLE_API + "/category/updateById",
    method: "post",
    data: data,
  });
}
// 删除装修分类
export function deleteDecorationCategory(ids = "") {
  return request({
    url: ARTICLE_API + "/category/deleteByIds",
    method: "delete",
    data: {
      ids: [ids],
    },
  });
}
/**
 * 文章管理----------------------------------------------------------
 *
 * @returns
 */
//{ categoryId, type, pageNum, pageSize }
// 查询文章列表
export function getArticleList(params) {
  return request({
    url: ARTICLE_API + "/page",
    method: "post",
    data: params,
  });
}
// 新增文章
export function addArticle(data) {
  return request({
    url: ARTICLE_API + "/add",
    method: "post",
    data: data,
  });
}
// 修改文章
export function updateArticle(data) {
  return request({
    url: ARTICLE_API + "/updateById",
    method: "post",
    data: data,
  });
}
// 删除文章
export function deleteArticle(id) {
  return request({
    url: ARTICLE_API + "/deleteByIds",
    method: "post",
    data: {
      ids: [id],
    },
  });
}

// 获取文章详细信息
export function getArticleDetail(id) {
  return request({
    url: ARTICLE_API + "/getDetailById",
    method: "get",
    params: {
      id: id,
    },
  });
}

/**
 * 评论管理----------------------------------------------------------
 *
 * @returns
 */
// 新增评论
export function addComment(data) {
  return request({
    url: ARTICLE_API_BASE + "/comment/add",
    method: "post",
    data: data,
  });
}
// 新增回复（评论回复）
export function addReply(data) {
  return request({
    url: ARTICLE_API_BASE + "/comment/appendById",
    method: "post",
    data: data,
  });
}
// 查询评论列表
export function getCommentList(params) {
  return request({
    url: ARTICLE_API_BASE + "/comment/getPreviewByArticleId",
    method: "get",
    params: params,
  });
}

// 获取评论详情
export function getCommentDetail({ firstParentId, pageNum, pageSize }) {
  return request({
    url: ARTICLE_API + "/comment/getReplayByParentId",
    method: "get",
    params: {
      firstParentId,
      pageNum,
      pageSize,
    },
  });
}

/**
 * 举报----------------------------------------------------------
 * @param data
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export function addFeedback(data) {
  return request({
    url: "/api/v1/feedback/add",
    method: "post",
    data,
  });
}

/**
 * 举报列表
 * @param data
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export function getFeedbackList(id) {
  return request({
    url: "/api/v1/feedback/children/" + id,
    method: "get",
  });
}
